package me.ree.zkproduct.config;

import me.ree.zkproduct.common.ConnectionPool;
import me.ree.zkproduct.common.impl.ConnectionPoolFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TestFactoryBeanConfig {

    @Bean
    public ConnectionPoolFactoryBean connectionPoolFactory() {
        ConnectionPoolFactoryBean factoryBean = new ConnectionPoolFactoryBean();
        factoryBean.setConnectionUrl("jdbc:mysql://127.0.0.1:3306/test_zk?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
        factoryBean.setUsername("test");
        factoryBean.setPassword("test123");
        return factoryBean;
    }

    @Bean
    public ConnectionPool connectionPool(ConnectionPoolFactoryBean connectionPoolFactory) throws Exception {
        return connectionPoolFactory.getObject();
    }
}
